package com.lxq.test1909.Main02;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();//果树数
        boolean[] isDrop = new boolean[n];//记录某棵树是否落果
        for (boolean b:isDrop
             ) {
            b = false;
        }
        int sum = 0;//总苹果数
        int dropTreeNum = 0;//落果 果树 棵数
        int group = 0;//组数

        //1分析每棵树的情况
        for (int i=0;i<n;i++){
            int m = sc.nextInt();//操作数
            int AppleNum=sc.nextInt();//记录本棵果树 苹果数

            for (int j=1;j<m;j++){
                int temp = sc.nextInt();
                if (temp<=0) AppleNum = AppleNum + temp;//进行疏果操作
                else if (temp<AppleNum) { //发生落果
                    //修正苹果数
                    AppleNum = temp;
                    //记录落果
                    if (!isDrop[i]) {
                        isDrop[i] = true;
                        dropTreeNum++;
                    }
                }
            }
            //记录每棵果树的苹果数量
            sum = sum + AppleNum;
        }
        //2.判断相邻果树的组数
        for (int i=1;i<n-1;i++) {
            if ((isDrop[i - 1])&&(isDrop[i])&&(isDrop[i + 1])) group++;
        }
        if ((isDrop[0])&&(isDrop[1])&&(isDrop[n - 1])) group++;
        if ((isDrop[0])&&(isDrop[n - 2])&&(isDrop[n - 1])) group++;

        //3.输出
        System.out.println(sum+" "+dropTreeNum+" "+group);

    }
}
